import React from 'react';
import {Input, DatePicker, Form, Button, message} from 'antd';
import form from '../_/form';
@form({
    data: "",
    newData: {
        Status: true,
        DisplayOrder: 0
    }
})
export default class myPatientSearch extends React.Component {
    doSearch = (e) => {
        e.preventDefault();
        e.stopPropagation();
        this.props.form.validateFieldsAndScroll((errors, values) => {
            if (errors) {
                return;
            }
            let isNull = false;
            for (const index in values) {
                if (values[index] !== null && typeof (values[index]) !== "undefined" && values[index] !== "") {
                    isNull = true;
                }
            }
            if (!isNull) {
                message.warning('查询条件不能为空。');
            } else if (typeof this.props.doSearch === 'function') {
                this.props.doSearch(values);
            }
        });
    };
    reSet = () => {
        this.props.form.resetFields();
    };

    render() {
        const {form} = this.props;
        const {getFieldDecorator: fp} = form;
        return (
            <Form inline className="padding-t-b">
                <Form.Item label="卡号：" hasFeedback>
                    {fp("BarCode")(<Input placeholder="卡号"/>)}
                </Form.Item>
                <Form.Item label="姓名：">
                    {fp("Name")(<Input placeholder="姓名"/>)}
                </Form.Item>
                <Form.Item label="就诊日期：">
                    {fp("visitDate")(<DatePicker/>)}
                </Form.Item>
                <Form.Item>
                    <Button type="primary" onClick={this.doSearch}>查找</Button>
                </Form.Item>
                <Form.Item>
                    <Button type="primary" onClick={this.reSet}>刷新</Button>
                </Form.Item>
            </Form>
        );
    }
}
